Inspectable - Make the output of a class instance in the console meaningful
Installation
Node.js 12.0.0 or newer is required
NPM
Recommended
npm i inspectable
Yarn
yarn add inspectable
Example usage
import { inspectable } from 'inspectable';
class APIRequest {
public method = 'pay';
private token = 'super-private';
}
const request = new APIRequest();
console.log(request);
inspectable(APIRequest, {
serialize(instance) {
return {
method: instance.method
};
}
});
console.log(request);
Decorators
import 'reflect-metadata';
import { Inspectable, Inspect } from 'inspectable';
@Inspectable({})
class APIRequest {
@Inspect
public method = 'pay';
private token = 'super-private';
}
const request = new APIRequest();
console.log(request);